package bookoperations;

import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 34255
 * Date: 2024-05-25
 * Time: 16:05
 */
    public class BorrowOperation implements IBookOperations{

        @Override
        public void work(BookList booklist) {
            System.out.println("请输入要借阅的图书名称");
            Scanner scanner = new Scanner(System.in);
            String name = scanner.nextLine();

            int i = 0;
            for (; i < booklist.getUseSize(); i++) {
                if(booklist.getBook(i).getName().equals(name)&&(booklist.getBook(i).isState() == false)){
                    booklist.getBook(i).setState(true);
                    System.out.println("借阅图书成功！！！");
                    return;
                }
            }

            System.out.println("您要借阅的图书不存在");
        }
    }
